package com.ucampus.controller;

import com.ucampus.entity.news;
import com.ucampus.service.newsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功能：
 * 作者： 启明星_Polaris
 * 日期：2025/1/10 下午8:32
 **/


@RestController
@RequestMapping("/news")
public class newsController {

    @Autowired
    private newsService service;

    // 获取全部新闻信息
    @GetMapping("/all")
    public List<news> getAllNews() {
        return service.getAllNews();
    }

    // 根据ID获取新闻信息
    @GetMapping("/{id}")
    public news getNewsById(@PathVariable int id) {
        return service.getNewsById(id);
    }
}
